<?php

namespace App\Http\Controllers\Test;

use App\Http\Controllers\Controller;
use App\Service\Curl;
use Illuminate\Support\Facades\Cache;


class CurlController extends Controller
{

    // 列表页面采集
    // www.option.com/test/curl/lists
    public function lists()
    {
        $url  = 'https://www.sjqcj.com/News/index?t=2';
        $url  = 'https://www.baidu.com';
        $curl = new Curl();
        //$res  = $curl->url($url)->proxy('118.112.202.154:80')->returnHeader(true)->request();
        //$res  = $curl->url($url)->proxy('127.0.0.1:80')->returnHeader(true)->request();
        //$res  = $curl->url($url)->proxy('118.31.71.77:22191')->returnHeader(true)->request();
        //$res  = $curl->url($url)->proxy('http://47.111.188.218:8888/')->returnHeader(true)->request();
        //$res  = $curl->url($url)->proxy('http://47.111.188.218:80/')->returnHeader(true)->request();
        //$res  = $curl->url($url)->proxy('47.111.188.218:80')->returnHeader(true)->request();
        //$res  = $curl->url($url)->proxy('111.224.213.62:8089')->returnHeader(true)->request();
        //$res  = $curl->url($url)->proxy('118.31.71.77:80')->returnHeader(true)->request();
        //$res  = $curl->url($url)->proxy('http://cdn.shenlannews.com:80/ss')->returnHeader(true)->request();
        $res = $curl->url($url)->proxy('http://114.231.8.19:8089')->returnHeader(true)->request();

        var_dump($res);
    }



    // 采集测试
    public function test()
    {
        $url    = 'https://api.jijinhao.com/realtime/quotejs.htm?codes=JO_9753%2CJO_92226%2CJO_9754%2CJO_71%2CJO_70%2CJO_76%2CJO_74%2CJO_73%2CJO_9751%2CJO_9752&currentPage=1&pageSize=11&_=1710829239234';
        $curl   = new Curl();
        $header = ['Authority:api.jijinhao.com','Method:GET','Path:/realtime/quotejs.htm?codes=JO_9753%2CJO_92226%2CJO_9754%2CJO_71%2CJO_70%2CJO_76%2CJO_74%2CJO_73%2CJO_9751%2CJO_9752&currentPage=1&pageSize=11&_=1710829239234','Scheme:https','Accept:*/*','Accept-Encoding: deflate, br','Accept-Language:zh-CN,zh;q=0.9','Referer:https://www.cngold.org/img_date/shangjiaosuo.html','Sec-Ch-Ua:"Google Chrome";v="113", "Chromium";v="113", "Not-A.Brand";v="24"','Sec-Ch-Ua-Mobile:?0','Sec-Ch-Ua-Platform:"Windows"','Sec-Fetch-Dest:script','Sec-Fetch-Mode:no-cors','Sec-Fetch-Site:cross-site','User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36',];
        $res    = $curl->url($url)->header($header)->returnHeader(true)->request();

        var_dump($res);
    }

}

